package cn.clwxy.gdz.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.clwxy.gdz.dao.StudentDao;
import cn.clwxy.gdz.dao.StudentDaoImpl;
import cn.clwxy.gdz.dao.TeacherDao;
import cn.clwxy.gdz.dao.TeacherDaoImpl;
import cn.clwxy.gdz.entity.Student;

public class CreatNewOrderFindPhoneServlet extends HttpServlet {
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		HttpSession session=request.getSession();
		String type=(String)session.getAttribute("type");
		Integer id=(Integer)session.getAttribute("id");
		String phone=request.getParameter("phone");
		if("1".equals(type)){
			StudentDao studentDao=new StudentDaoImpl();
			String realPhone=studentDao.getStudentPhoneById(id);
			if(realPhone.equals(phone)){
				response.getWriter().write("1");
			}
			
			
		}else if("2".equals(type)){
			TeacherDao teacherDao=new TeacherDaoImpl();
			String realPhone=teacherDao.findTeacherById(id);
			if(realPhone.equals(phone)){
				response.getWriter().write("1");
			}
			
			
		}
		response.getWriter().write("0");
	}
}
